package com.socket.socketObjTest;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * PetServer--bdqnPractice
 *
 * @author: Jovi
 * @createTime: 2017-09-14 10:49
 **/
public class PetServer {

    public static void main(String[] args) throws IOException, ClassNotFoundException {

        ServerSocket ss = new ServerSocket(8989);

        Socket socket = ss.accept();

        InputStream is = socket.getInputStream();

        ObjectInputStream ois = new ObjectInputStream(is);

        Pet p = (Pet)ois.readObject();

        System.out.println("========");
        System.out.println(p);

        String repay = "congratulations";

        OutputStream os = socket.getOutputStream();
        PrintWriter pw = new PrintWriter(os);

        pw.write(repay);
        pw.flush();
        pw.close();
        os.close();
        ois.close();
        is.close();
        socket.close();
        ss.close();
    }

}
